/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package graphicswithsomebackup;

import java.awt.Graphics;
import java.awt.Image; //image ;P

import javax.swing.ImageIcon;

/**
 *
 * @author Martin Wilhelmsson
 */
public class BackGround {


    // --------- Primitive types -------------
    private int panelWidth, panelHeight;
    private int upperLeftCornerX = 0;
    private int upperLeftCornerY = 0;
    private boolean fetchingValues = true;//used in getTheWidAndHeightValues to fetch the panelwid- and panelheight-values.
    //.........................................
    // ----------Reference types -------------
    private MouseLocator mousePositions = new MouseLocator();
    private GamePanel superPanel;
    //.........................................

    //_.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._
    //_.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._.-:^:-._

    //----------- BackGround -----------
    private Image backgroundImage;
    private int backgroundX1 = upperLeftCornerX;
    private int backgroundY1 = upperLeftCornerY;
    private int backgroundX2 = upperLeftCornerX;
    private int backgroundY2 = -panelHeight;
    //...................................
    
    public BackGround(int panelWidth, int panelHeight) {

        this.panelWidth = panelWidth;
        this.panelHeight = panelHeight;
        backgroundImage = new ImageIcon("images/space.gif").getImage();
    }
    
    public void drawBackGround(Graphics g) {
        if(++backgroundY1 >= panelHeight)
            backgroundY1 = 0;
        if(++backgroundY2 >= 0)
            backgroundY2 = -panelHeight;
        g.drawImage(backgroundImage, backgroundX1, backgroundY1, panelWidth, panelHeight, superPanel); // checka keyPressed för att se hur rörelser går till
        g.drawImage(backgroundImage, backgroundX2, backgroundY2, panelWidth, panelHeight, superPanel); // checka keyPressed för att se hur rörelser går till
    }

}
